<%--
  header.jsp
  作用：网站的通用头部导航栏，包含网站标题、用户登录/登出状态和当前用户头像。
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<header class="main-header">
    <h1>沈阳工程学院二手交易市场</h1>
    <div class="header-user-actions">
        <c:choose>
            <c:when test="${not empty sessionScope.user}">
                <a href="${pageContext.request.contextPath}/user/profile" class="header-link">
                    <img src="${pageContext.request.contextPath}/uploads/avatars/${sessionScope.user.avatar}" alt="头像" class="header-avatar">
                    <span>${sessionScope.user.username}</span>
                </a>
                <a href="${pageContext.request.contextPath}/user/messages" class="header-link message-notification">
                    我的消息
                    <c:if test="${sessionScope.unreadMessageCount > 0}">
                        <span class="badge">${sessionScope.unreadMessageCount}</span>
                    </c:if>
                </a>
                <a href="${pageContext.request.contextPath}/logout" class="header-link">退出登录</a>
            </c:when>
            <c:otherwise>
                <a href="${pageContext.request.contextPath}/login.jsp">登录</a>
                <span>/</span>
                <a href="${pageContext.request.contextPath}/register.jsp">注册</a>
            </c:otherwise>
        </c:choose>
    </div>
</header> 